<?php

/**
 * @Author: suyuan
 * @Email: 819067126@qq.com
 * @Date: 2020/11/13 09:50
 */

namespace app\api\controller\v1;

use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;
use Exception;

class Banner
{
    /**
     * 获取指定id的 banner信息
     * @DateTime 2020-11-13
     * @param [type] $id
     * @return void
     */
    public function getBanner($id)
    {
        (new IDMustBePositiveInt())->goCheck();
    
        $banner = BannerModel::getBannerById($id);
        // $banner->hidden(['update_time','delete_time']);
        // $banner->visible(['id']);
        if ($banner->isEmpty()) {
            throw new BannerMissException();
        }
        
        return $banner;
    }
}
